"""
Database configuration settings
"""

# Database connection settings
DB_CONFIG = {
    'host': '117.72.104.65',
    'port': 3306,
    'user': 'diy',
    'password': 'A!hongdou36',
    'database': 'lets_diy'
}

# Connection pool settings
POOL_CONFIG = {
    'pool_size': 5,  # 连接池大小
    'max_overflow': 10,  # 最大溢出连接数
    'pool_timeout': 30,  # 连接池获取连接的超时时间
    'pool_pre_ping': True,  # 每次连接前ping一下数据库，确保连接有效
    'echo': False,  # 不打印SQL语句
    'pool_use_lifo': True,  # 使用后进先出策略，保持连接更活跃
}

# SQLAlchemy database URL
def get_db_url():
    """Get SQLAlchemy database URL"""
    return f"mysql+pymysql://{DB_CONFIG['user']}:{DB_CONFIG['password']}@{DB_CONFIG['host']}:{DB_CONFIG['port']}/{DB_CONFIG['database']}?charset=utf8mb4&connect_timeout=60&read_timeout=60&write_timeout=60" 